﻿using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Product.Domain;
using Product.Domain.Entity;
using Product.WebAPi.Controllers.Response;

namespace Product.WebAPi.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class ProductVariantController : ControllerBase
    {
        private readonly IProductVariantRepository _productVariantRepository;

        public ProductVariantController(IProductVariantRepository productVariantRepository)
        {
            _productVariantRepository = productVariantRepository;
        }

        [HttpGet("{productId}/{productTypeId}")]
        public async Task<ActionResult<ServiceResponse<ProductVariant>>> GetVariantByProduct(Guid productId, Guid productTypeId)
        {
            var result = await _productVariantRepository.GetVariantByProductAsync(productId, productTypeId);
            var resp = new ServiceResponse<ProductVariant>() { Data = result };

            return Ok(resp);
        }
    }
}
